<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户管理</title>
<link href="../../../static/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../../static/js/jquery.js"></script>
  <script type="text/javascript" src="../../../static/js/jq-paginator.js"></script>
  <script>
    //查询条件
    window.datas = {
      conditionInfo: {
        pageNum: "1",
        pageSize: "5",
      },
      status:["未审核","审核中","审核通过","审核不通过"],
    }
    //获取condition参数
    function getCondition(){
      this.datas.conditionInfo={
        pageNum:1,
        pageSize:5,
        orderid:$(".orderid").val(),
        customName:$(".customName").val(),
        beOrdertime:$(".beOrdertime").val(),
        afOrdertime:$(".afOrdertime").val(),
        beOrdermoney:$(".beOrdermoney").val(),
        afOrdermoney:$(".afOrdermoney").val(),
        checkId:JSON.parse(localStorage.getItem("user")).uid
      }
    }
    //获取分页信息
    function getOrdersPage(conditionInfo) {
      $.ajax({
        url: `/orderExamine`,
        type: "post",
        dataType: "json",
        contentType: "application/json;charset=utf8",
        data: JSON.stringify(conditionInfo),
        success: (data) => {
          datas.resultInfo = data.data;
          if(!data.data.totalPage){
            datas.resultInfo.totalPage=1;
          }
          reder();
          $('.paginList').jqPaginator('option', {
            totalPages: datas.resultInfo.totalPage,
          });
        }
      })
    }
    //数据渲染到页面
    function reder() {
      let customInfo = this.datas.resultInfo.data;
      $(".formbody").html("");
      customInfo.forEach((item, index) => {
        $(".formbody").append(` <tr>
                <td>${(datas.resultInfo.pageNum-1)*datas.resultInfo.pageSize+index+1}</td>
                <td>${item.orderid}</td>
                <td>${item.customName}</td>
                <td>${item.telephone}</td>
                <td>${item.ordertime}</td>
                <td>￥${item.ordermoney}</td>
                <td>${item.operatorName}</td>
                <td>${datas.status[item.status-1]}</td>
                <td>
                    <a href="orderExamine?orderid=${item.orderid}" class="tablelink">审核</a>
                </td>
            </tr>`)
      });
      $(".blue").eq(0).text(this.datas.resultInfo.totalCount);
      $(".blue").eq(1).text(this.datas.resultInfo.pageNum);
    }
    //点击查询时
    function search() {
      datas.conditionInfo.pageNum = 1;
      getCondition();
      getOrdersPage(datas.conditionInfo);
    }
    $(()=> {
      //初始化分页器
      $(".paginList").jqPaginator({
        totalPages: 10,
        visiblePages: 10,
        currentPage: 1,
        activeClass: 'current',
        disableClass: 'disabled',
        prev: '<li class="prev paginItem"><a><span class="pagepre"></span></a></li>',
        next: '<li class="next paginItem"><a><span class="pagenxt"></span></a></li>',
        page: '<li class="page paginItem"><a>{{page}}</a></li>',
        onPageChange: (num) => {
          getCondition();
          datas.conditionInfo.pageNum = num;
          getOrdersPage(window.datas.conditionInfo);
        }
      });
    })
  </script>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>订购单审核管理</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form action="" method="post">
    <ul class="tools">
      <li> 订单编号:
        <input type="text" class="orderid"/>
      </li>
      <li> 客户姓名:
        <input type="text" class="customName"/>
      </li>
      <li> 订购时间:
        <input type="date" class="beOrdertime"/>-<input type="date" class="afOrdertime"/>
      </li>
      <li> 金额:
        <input type="text" class="stinput beOrdermoney"/>-<input type="text" class="stinput afOrdermoney"/>
      </li>
      <li class="subBut" onclick="search()"><img src="../../../static/images/t06.png"/>查询
      </li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>订单编号</th>
          <th>客户姓名</th>
          <th>联系电话</th>
          <th>订购时间</th>
          <th>金额</th>
          <th>操作人</th>
          <th>审核状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody class="formbody">

      </tbody>
    </table>
    <div class="pagin">
      <div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>
      <ul class="paginList">
      </ul>
    </div>
  </form>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
